<?php
namespace Think\Template\TagLib;
use Think\Template\TagLib;
/**
 * Advert 标签库解析类
 */
class Advert extends TagLib {

	// 标签定义
	protected $tags   =  array(
		// 标签定义： attr 属性列表 close 是否闭合（0 或者1 默认1） alias 标签别名 level 嵌套层次
		'showads'    => array('attr'=>'id,cid,limit,device,type','close'=>1),
		);

	/**
	 * 展示广告
	 * @param <type> $cid
	 * @param <type> $limit
	 * @return string
	 */
	public function _showads($tag,$content) {
		$id			= $tag['id'];
		$cid		= $tag['cid'];
		$limit		= $tag['limit'];
		$device		= $tag['device'];
		$type		= $tag['type'];
		$Advert		= D("Advert");
		$map		= array(
			"id"	=> $id,
			"cid"	=> $cid,
		);
		$info = $Advert->where($map)->field('id,content')->select();
		$parseStr	= "<!-- ID_{$info[0]['id']} -->{$info[0]['content']}";
		return $parseStr;
	}

}
